﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FrameWork.Setting;

namespace ServerUI.Setting
{
   

    public partial class ServerUIRateSettingEditor : SettingEditorBase
    {
        public ServerUIRateSettingEditor()
        {
            InitializeComponent();
        }
    }
    public sealed class ServerUISettingEditorItem:SettingEditorItem
    {
        private ServerUIRateSettingEditor BaseEditor;
        public override bool SaveSetting(SettingOperatorBase SettingOper)
        {
            return SettingOper.OperateSettingFromObject(null, typeof(ServerUIRateSetting), false);
        }

        public override bool LoadSetting(SettingOperatorBase SettingOper)
        {
            return SettingOper.OperateSettingFromObject(null, typeof(ServerUIRateSetting), true);
        }

        public override bool AcceptSetting()
        {
            ServerUIRateSetting.BitmapRefreshRate = (int)BaseEditor.nudBmpRefRate.Value;
            ServerUIRateSetting.ControlRate = (int)BaseEditor.nudControlRefRate.Value;
            ServerUIRateSetting.ServerStatsWndRefreshRate = (int)BaseEditor.nudInfoRefRate.Value;
            return true;
        }

        public override bool ResetEditor()
        {
            BaseEditor.nudBmpRefRate.Value = ServerUIRateSetting.BitmapRefreshRate;
            BaseEditor.nudControlRefRate.Value = ServerUIRateSetting.ControlRate;
            BaseEditor.nudInfoRefRate.Value = ServerUIRateSetting.ServerStatsWndRefreshRate;
            return true;
        }

        public override bool ResetToDefault()
        {
            return false;
        }

        public override string GetShowName()
        {
            return @"服务端设定\频率设定";
        }

        public ServerUISettingEditorItem()
        {
            base.Editor = new ServerUIRateSettingEditor();
            this.BaseEditor =(ServerUIRateSettingEditor)base.Editor;
        }
    }
}
